﻿using System;
using System.Drawing;
using System.Data.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Media;

namespace MVVM.Northwind.Employee.View
{
    public class BinaryToImageConverter:IValueConverter
    {

        //ImageSource ImageFromBits(Binary bits)
        //{
        //    ImageConverter converter = new System.Drawing.ImageConverter();
        //    Bitmap bmp = converter.ConvertFrom(;
        //}

        object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
            {
                return null;
            }
            else
            {
                Binary sourceImage = (Binary)value;
                byte[] image = sourceImage.ToArray();                
                return image;
            }   
            
        }

        object IValueConverter.ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        
    }
}
